package ustc.xiaoyang.karl.simulation;

import java.util.Scanner;

/**
 *  卡玛网 58.区间和
 */
public class IntervalSum {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] sum = new int[n];
        int[] p = new int[n];
        for (int i = 0; i < n; i++) {
            p[i] = sc.nextInt();
            if(i != 0){
                sum[i] = sum[i-1] + p[i];
            }else sum[i] = p[i];
        }

        while(sc.hasNextInt()){
            int a = sc.nextInt();
            int b = sc.nextInt();
            if (a!=0)
                System.out.println(sum[b] - sum[a-1]);
            else{
                System.out.println(sum[b]);
            }
        }

    }
}
